
clear all
set more off

**********************************
*** Set where is the dataset and upload it
**********************************

use "D:\Dropbox\1. Research\0. Pubblications\2020 RESTat\RESTAT\2. Tex & Replication\1.data_vendors.dta"

******************
***Proper construction of the time lags
***Taking care of the missing values
******************

forval i = 1/3{

gen after_`i' = 0 
replace after_`i' = 1 if new_month > new_month_W`i' & new_month_W`i'!=.
replace after_`i' = 1 if new_month == new_month_W`i' & day_interview > day_W`i'

gen T_after_`i' = T*after_`i'
gen T1_after_`i' = T1*after_`i'
gen T2_after_`i' = T2*after_`i'

}

forval i = 1/3{
gen after_`i'_lag_0 = 0
gen after_`i'_lag_1 = 0
gen after_`i'_lag_2 = 0
gen after_`i'_lag_3 = 0
replace after_`i'_lag_0 = 1 if (new_month - new_month_W`i' == 0 & new_month_W`i'!=.)
replace after_`i'_lag_1 = 1 if (new_month - new_month_W`i' == 1 & new_month_W`i'!=.)
replace after_`i'_lag_2 = 1 if (new_month - new_month_W`i' == 2 & new_month_W`i'!=.)
replace after_`i'_lag_3 = 1 if (new_month - new_month_W`i' >= 3 & new_month_W`i'!=.)

}

tab after_1_lag_0
distinct id if  after_1_lag_0==1
tab after_1_lag_1
distinct id if  after_1_lag_1==1
tab after_1_lag_2
distinct id if  after_1_lag_2==1
tab after_1_lag_3
distinct id if  after_1_lag_3==1
tab after_2_lag_0
distinct id if  after_2_lag_0==1
tab after_2_lag_1
distinct id if  after_2_lag_1==1
tab after_2_lag_2
distinct id if  after_2_lag_2==1
tab after_2_lag_3
distinct id if  after_2_lag_3==1
tab after_3_lag_0
distinct id if  after_3_lag_0==1
tab after_3_lag_1
distinct id if  after_3_lag_1==1
tab after_3_lag_2
distinct id if  after_3_lag_2==1
tab after_3_lag_3
distinct id if  after_3_lag_3==1

***For a lot of vendors, info on W3 is missing
***Creating lag for LAST workshop: 

gen lag = new_month- new_month_W3
replace lag = new_month - new_month_W2 if (new_month_W3==. & T==1)
replace lag = new_month - new_month_W1 if (new_month_W3==. & new_month_W2==. & T==1)

gen T_lag2 = T*(lag == 2)
gen T_lag3 = T*(lag == 3)
gen T_lag4 = T*(lag == 4)
gen T_lag5 = T*(lag == 5)


*** 
gen end = 0
replace end = 1 if period>0

gen T_end = 0
replace T_end = 1 if T & end

gen T1_end = 0
replace T1_end = 1 if T1 & end

gen T2_end = 0
replace T2_end = 1 if T2 & end


* Poverty line (1.90$/day in PPP)
* Taken from here: https://data.oecd.org/conversion/purchasing-power-parities-ppp.htm
gen profits_us_dollar = profits/17.240
gen poor = (profits_us_dollar<1.90)
replace poor = . if profits == .


* Generating dummies ANY for awareness *

gen food_hygiene_any = (food_hygiene_cover==1| food_hygiene_separate==1| food_hygiene_store==1| food_hygiene_handle==1| food_hygiene_wash==1| food_hygiene_cleanwater==1| food_hygiene_cleanutensils==1)
gen per_hygiene_any = (per_hygiene_cleanhands==1| per_hygiene_soap==1| per_hygiene_cleanclothes==1| per_hygiene_nails==1| per_hygiene_apron==1| per_hygiene_caps==1| per_hygiene_gloves==1| per_hygiene_baths==1| per_hygiene_cleanwater==1)
gen contamination_any = (contamination_bacteria==1| contamination_oil==1| contamination_spices==1| contamination_bug==1| contamination_dirt==1| contamination_water==1)
gen utensils_any = (utensils_servefood==1| utensils_avoidgerms==1| utensils_avoidsickness==1| utensils_touchingfoorhands==1)


*** Global for results

global food_type	"food_light food_heavy food_meal food_liquid food_fruits food_sweets food_otheropt"
global control		"age male owner i.education years_vend cooked_food $food_type i.area i.enumerator union1-union12 tot_close_pilot"


**********************************
***TABLE 1
**********************************

* Distinct
foreach x in T1 T2 T0{
distinct area if `x'==1 & period==0
}
foreach x in T1 T2 T0{
distinct block if `x'==1 & period==0
}
distinct block if period==0 & pilot==0


* Observations per period
forval i=0/5{
tab T1 if period==`i' & pilot==0
tab T2 if period==`i' & pilot==0
tab T0 if period==`i' & pilot==0
}



**********************************
*** TABLE 2 (clustered difference)
**********************************

gen milk2 = (milk == 6)
replace milk2 = . if milk == .

***T1 vs T2

local varlist national_act cont_bacteria cont_oil cont_spice cont_insect cont_dirt cont_water cont_other milk2 

tokenize `varlist'

forval i = 1/7{
reg ``i'' T1 if period==0 & (T1==1 | T2 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' , p(%7.4f) keep (T1)

***T1 vs T0

local varlist national_act cont_bacteria cont_oil cont_spice cont_insect cont_dirt cont_water cont_other milk2 

tokenize `varlist'

forval i = 1/7{
reg ``i'' T1 if period==0 & (T1==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' , p(%7.4f) keep (T1)

***T2 vs T0

local varlist national_act cont_bacteria cont_oil cont_spice cont_insect cont_dirt cont_water cont_other milk2 

tokenize `varlist'

forval i = 1/7{
reg ``i'' T2 if period==0 & (T2==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' , p(%7.4f) keep (T2)



**********************************
*** TABLE 3 (clustered difference)
**********************************


***Socio: "male age years_vending union_member"

gen some_edu = (edu!=1)
gen n_avg_know = (p1_know_tot + p2_know_tot)/2

***T1 vs T2

local varlist male age years_vending some_edu union_member ///
cooked_food food_light food_heavy food_meal food_liquid food_fruits food_sweets food_else ///
revenue expenditure profits hours hourly_wage ///
localauth prob_electric prob_capital prob_compvendor prob_complarge prob_toilets prob_water prob_police prob_clubs  ///
s_know_tot n_avg_know ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total

tokenize `varlist'

forval i = 1/33{
reg ``i'' T1 if period==0 & (T1==1 | T2 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' `17' `18' `19' `20' `21' `22' `23' `24' `25' ///
`26' `27' `28' `29' `30' `31' `32' `33', p(%7.4f) keep (T1)

***T1 vs T0

local varlist male age years_vending some_edu union_member ///
cooked_food food_light food_heavy food_meal food_liquid food_fruits food_sweets food_else ///
revenue expenditure profits hours hourly_wage ///
localauth prob_electric prob_capital prob_compvendor prob_complarge prob_toilets prob_water prob_police prob_clubs  ///
s_know_tot n_avg_know ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total

tokenize `varlist'

forval i = 1/33{
reg ``i'' T1 if period==0 & (T1==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' `17' `18' `19' `20' `21' `22' `23' `24' `25' ///
`26' `27' `28' `29' `30' `31' `32' `33', p(%7.4f) keep (T1)

***T2 vs T0

local varlist male age years_vending some_edu union_member ///
cooked_food food_light food_heavy food_meal food_liquid food_fruits food_sweets food_else ///
revenue expenditure profits hours hourly_wage ///
localauth prob_electric prob_capital prob_compvendor prob_complarge prob_toilets prob_water prob_police prob_clubs  ///
s_know_tot n_avg_know ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total

tokenize `varlist'

forval i = 1/33{
reg ``i'' T2 if period==0 & (T2==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' `17' `18' `19' `20' `21' `22' `23' `24' `25' ///
`26' `27' `28' `29' `30' `31' `32' `33', p(%7.4f) keep (T2)



**********************************
*** TABLE 4 (clustered difference)
**********************************

***T1 vs T2

local varlist food_hygiene_any per_hygiene_any contamination_any utensils_any ///
ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total ///

tokenize `varlist'

forval i = 1/16{
reg ``i'' T1 if period==5 & (T1==1 | T2 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' , p(%7.4f) keep (T1)

***T1 vs T0

local varlist food_hygiene_any per_hygiene_any contamination_any utensils_any ///
ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total ///

tokenize `varlist'

forval i = 1/16{
reg ``i'' T1 if period==5 & (T1==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' , p(%7.4f) keep (T1)

***T2 vs T0

local varlist food_hygiene_any per_hygiene_any contamination_any utensils_any ///
ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet ///
p_ind_facilities p_ind_handling p_ind_costumer p_ind_total ///

tokenize `varlist'

forval i = 1/16{
reg ``i'' T2 if period==5 & (T2==1 | T0 == 1), r cluster(block)
eststo ``i''
}
estimates table `1' `2' `3' `4' `5' `6' `7' `8' `9' `10' `11' `12' `13' `14' `15' `16' , p(%7.4f) keep (T2)





**********************************
**********************************
**********************************
*** Results
**********************************
**********************************
**********************************


**********************************
***TABLE 5: AWARENESS
**********************************

***Unique treatment

foreach x in food_hygiene_any per_hygiene_any contamination_any utensils_any{
quietly{
reg `x' T $control if period==5, r cluster(block)
est store `x'
}
}

quietly sum food_hygiene_any if T0 & period==5 & pilot==0
outreg2 [food_hygiene_any] 	using "aware1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum per_hygiene_any if T0 & period==5 & pilot==0
outreg2 [per_hygiene_any] 	using "aware1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum contamination_any if T0 & period==5 & pilot==0
outreg2 [contamination_any] using "aware1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum utensils_any if T0 & period==5 & pilot==0
outreg2 [utensils_any] 		using "aware1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Separate treatment 

foreach x in food_hygiene_any per_hygiene_any contamination_any utensils_any{
quietly{
reg `x' T1 T2 $control if period==5, r cluster(block)
est store `x'
}
test T1=T2
}

quietly sum food_hygiene_any if T0 & period==5 & pilot==0
outreg2 [food_hygiene_any] 	using "aware2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum per_hygiene_any if T0 & period==5 & pilot==0
outreg2 [per_hygiene_any] 	using "aware2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum contamination_any if T0 & period==5 & pilot==0
outreg2 [contamination_any] using "aware2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum utensils_any if T0 & period==5 & pilot==0
outreg2 [utensils_any] 		using "aware2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Unique treatment with time lag

foreach x in food_hygiene_any per_hygiene_any contamination_any utensils_any{
quietly{
reg `x' T_lag2 T_lag3 T_lag4 T_lag5 $control if period==5, r cluster(block)
est store `x'
}
test T_lag2= T_lag3= T_lag4= T_lag5
}


quietly sum food_hygiene_any if T0 & period==5 & pilot==0
outreg2 [food_hygiene_any] 	using "aware3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum per_hygiene_any if T0 & period==5 & pilot==0
outreg2 [per_hygiene_any] 	using "aware3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum contamination_any if T0 & period==5 & pilot==0
outreg2 [contamination_any] using "aware3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum utensils_any if T0 & period==5 & pilot==0
outreg2 [utensils_any] 		using "aware3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))



**********************************
***TABLE 6: CLAIMED ACTION
**********************************

***Unique treatment

foreach x in ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet{
quietly{
reg `x' T $control if period==5, r cluster(block)
est store `x'
}
}

quietly sum ad_discuss if T0 & period==5 & pilot==0
outreg2 [ad_discuss] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info if T0 & period==5 & pilot==0
outreg2 [ad_info] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum ad_improve if T0 & period==5 & pilot==0
outreg2 [ad_improve] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_buy if T0 & period==5 & pilot==0
outreg2 [ad_buy] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_Act if T0 & period==5 & pilot==0
outreg2 [ad_disc_Act] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info_Act if T0 & period==5 & pilot==0
outreg2 [ad_info_Act] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_union if T0 & period==5 & pilot==0
outreg2 [ad_disc_union] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_meet if T0 & period==5 & pilot==0
outreg2 [ad_meet] using "claimact1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))




***Separate treatment 

foreach x in ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet{
quietly{
reg `x' T1 T2 $control if period==5, r cluster(block)
est store `x'
}
test T1=T2
}

quietly sum ad_discuss if T0 & period==5 & pilot==0
outreg2 [ad_discuss] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info if T0 & period==5 & pilot==0
outreg2 [ad_info] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum ad_improve if T0 & period==5 & pilot==0
outreg2 [ad_improve] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_buy if T0 & period==5 & pilot==0
outreg2 [ad_buy] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_Act if T0 & period==5 & pilot==0
outreg2 [ad_disc_Act] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info_Act if T0 & period==5 & pilot==0
outreg2 [ad_info_Act] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_union if T0 & period==5 & pilot==0
outreg2 [ad_disc_union] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_meet if T0 & period==5 & pilot==0
outreg2 [ad_meet] using "claimact2.xls", excel se append dec(3) keep(T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Unique treatment with time lag

foreach x in ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet{
quietly{
reg `x' T_lag2 T_lag3 T_lag4 T_lag5 $control if period==5, r cluster(block)
est store `x'
}
test T_lag2= T_lag3= T_lag4= T_lag5
}



quietly sum ad_discuss if T0 & period==5 & pilot==0
outreg2 [ad_discuss] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info if T0 & period==5 & pilot==0
outreg2 [ad_info] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum ad_improve if T0 & period==5 & pilot==0
outreg2 [ad_improve] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_buy if T0 & period==5 & pilot==0
outreg2 [ad_buy] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_Act if T0 & period==5 & pilot==0
outreg2 [ad_disc_Act] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_info_Act if T0 & period==5 & pilot==0
outreg2 [ad_info_Act] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_disc_union if T0 & period==5 & pilot==0
outreg2 [ad_disc_union] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum ad_meet if T0 & period==5 & pilot==0
outreg2 [ad_meet] using "claimact3.xls", excel se append dec(3) keep(T_lag2 T_lag3 T_lag4 T_lag5) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))



**********************************
***TABLE 7: BEHAVIOR, DIFF 
**********************************

***Unique treatment

foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
quietly{
areg `x' T $control, r absorb(period) cluster(block)
est store `x'
}
}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0
outreg2 [p_ind_facilities] using "beh1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0 
outreg2 [p_ind_handling] using "beh1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "beh1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "beh1.xls", excel se append dec(3) keep( T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Separate Treatment

foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
quietly{
areg `x' T1 T2 $control, r absorb(period) cluster(block)
est store `x'
}
test T1=T2
}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 
outreg2 [p_ind_facilities] using "beh2.xls", excel se append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0 
outreg2 [p_ind_handling] using "beh2.xls", excel se append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "beh2.xls", excel se append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "beh2.xls", excel se append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))



**********************************
***TABLE 8: Cost to Change
**********************************

***Unique Treatment 

foreach x in water_weight dustbin_weight cloths_weight cookingarea_weight disposable_weight{
quietly{
areg `x' T_end T end $control if period==0|period==5, r absorb(period) cluster(block)
est store `x'
}
}

quietly sum water_weight if T0 & period==0|period==5
outreg2 [water_weight] using "cost1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum dustbin_weight if T0 & period==0|period==5
outreg2 [dustbin_weight] using "cost1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cloths_weight if T0 & period==0|period==5
outreg2 [cloths_weight] using "cost1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cookingarea_weight if T0 & period==0|period==5
outreg2 [cookingarea_weight] using "cost1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum disposable_weight if T0 & period==0|period==5
outreg2 [disposable_weight] using "cost1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Separate Treatment 

foreach x in water_weight dustbin_weight cloths_weight cookingarea_weight disposable_weight{
quietly{
areg `x' T1_end T2_end T1 T2 end $control if period==0|period==5, r absorb(period) cluster(block)
est store `x'
}
test T1_end=T2_end
}


quietly sum water_weight if T0 & period==0|period==5
outreg2 [water_weight] using "cost2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum dustbin_weight if T0 & period==0|period==5
outreg2 [dustbin_weight] using "cost2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cloths_weight if T0 & period==0|period==5
outreg2 [cloths_weight] using "cost2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cookingarea_weight if T0 & period==0|period==5
outreg2 [cookingarea_weight] using "cost2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum disposable_weight if T0 & period==0|period==5
outreg2 [disposable_weight] using "cost2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


***Separately for problem and no problem: 

gen prob = (period == 0 & (prob_capital ==1 | prob_compvendor==1 | prob_complarge==1 | prob_toilets==1 | prob_water==1 | prob_police==1| prob_clubs==1 | prob_org==1 | prob_other==1))
gen noprob = (period == 0 & (prob_capital ==0 & prob_compvendor==0 & prob_complarge==0 & prob_toilets==0 & prob_water==0 & prob_police==0 & prob_clubs==0 & prob_org==0 & prob_other==0 ))

bys id: egen prob_bus = max(prob)
bys id: egen noprob_bus = max(noprob)

foreach x in water_weight dustbin_weight cloths_weight cookingarea_weight disposable_weight{
quietly{
areg `x' T_end T end $control if prob_bus==1 & (period==0|period==5), r absorb(period) cluster(block)
est store `x'
}
}

quietly sum water_weight if T0 & prob_bus==1 & (period==0|period==5)
outreg2 [water_weight] using "cost_pr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum dustbin_weight if T0 & prob_bus==1 & (period==0|period==5)
outreg2 [dustbin_weight] using "cost_pr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cloths_weight if T0 & prob_bus==1 & (period==0|period==5)
outreg2 [cloths_weight] using "cost_pr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cookingarea_weight if T0 & prob_bus==1 & (period==0|period==5)
outreg2 [cookingarea_weight] using "cost_pr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum disposable_weight if T0 & prob_bus==1 & (period==0|period==5)
outreg2 [disposable_weight] using "cost_pr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))



foreach x in water_weight dustbin_weight cloths_weight cookingarea_weight disposable_weight{
quietly{
areg `x' T_end T end $control if noprob_bus==1 & (period==0|period==5), r absorb(period) cluster(block)
est store `x'
}
}

quietly sum water_weight if T0 & noprob_bus==1 & (period==0|period==5)
outreg2 [water_weight] using "cost_nopr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum dustbin_weight if T0 & noprob_bus==1 & (period==0|period==5)
outreg2 [dustbin_weight] using "cost_nopr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cloths_weight if T0 & noprob_bus==1 & (period==0|period==5)
outreg2 [cloths_weight] using "cost_nopr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum cookingarea_weight if T0 & noprob_bus==1 & (period==0|period==5)
outreg2 [cookingarea_weight] using "cost_nopr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum disposable_weight if T0 & noprob_bus==1 & (period==0|period==5)
outreg2 [disposable_weight] using "cost_nopr.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))





********************************************************************************
***APPENDIX
********************************************************************************


**********************************
***TABLE A.1: BEHAVIOR, DIFF-in-DIFF
**********************************

*** Treatment * After each workshop

***Unique Treatment 

foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	qui areg `x' T_after_1 T $control, absorb(period) cluster(block)
	est store `x'
	}
	
quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDD1.xls", excel se append dec(3) keep( T_after_1 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDD1.xls", excel se append dec(3) keep( T_after_1 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "behDD1.xls", excel se append dec(3) keep( T_after_1 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDD1.xls", excel se append dec(3) keep( T_after_1 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))


foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	qui areg `x' T_after_2 T $control, absorb(period) cluster(block)
	est store `x'
	}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDD2.xls", excel se append dec(3) keep( T_after_2 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDD2.xls", excel se append dec(3) keep( T_after_2 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "behDD2.xls", excel se append dec(3) keep( T_after_2 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDD2.xls", excel se append dec(3) keep( T_after_2 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))

	
	
foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	qui areg `x' T_after_3 T $control, absorb(period) cluster(block)
	est store `x'
	}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDD3.xls", excel se append dec(3) keep( T_after_3 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDD3.xls", excel se append dec(3) keep( T_after_3 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "behDD3.xls", excel se append dec(3) keep( T_after_3 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDD3.xls", excel se append dec(3) keep( T_after_3 T) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))

	
	
**********************************
***TABLE A.2: BEHAVIOR, DIFF-in-DIFF 
**********************************

***Separate Treatment

foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	quietly{
	areg `x' T1_after_1 T2_after_1 T1 T2 $control, absorb(period) cluster(block)
	est store `x'
	}
	test T1_after_1 = T2_after_1
	}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDDS1.xls", excel se append dec(3) keep( T1_after_1 T2_after_1 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDDS1.xls", excel se append dec(3) keep( T1_after_1 T2_after_1 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer if T0 & period==0 & pilot==0 
outreg2 [p_ind_costumer] using "behDDS1.xls", excel se append dec(3) keep( T1_after_1 T2_after_1 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDDS1.xls", excel se append dec(3) keep( T1_after_1 T2_after_1 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))	



foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	quietly{
	areg `x' T1_after_2 T2_after_2 T1 T2 $control, absorb(period) cluster(block)
	est store `x'
	}
	test T1_after_2 = T2_after_2
	}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDDS2.xls", excel se append dec(3) keep( T1_after_2 T2_after_2 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDDS2.xls", excel se append dec(3) keep( T1_after_2 T2_after_2 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer  if T0 & period==0 & pilot==0
outreg2 [p_ind_costumer] using "behDDS2.xls", excel se append dec(3) keep( T1_after_2 T2_after_2 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDDS2.xls", excel se append dec(3) keep( T1_after_2 T2_after_2 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))	


foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
	quietly{
	areg `x' T1_after_3 T2_after_3 T1 T2 $control, absorb(period) cluster(block)
	est store `x'
	}
	test T1_after_3 = T2_after_3
	}

quietly sum p_ind_facilities if T0 & period==0 & pilot==0 	
outreg2 [p_ind_facilities] using "behDDS3.xls", excel se append dec(3) keep( T1_after_3 T2_after_3 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_handling if T0 & period==0 & pilot==0
outreg2 [p_ind_handling] using "behDDS3.xls", excel se append dec(3) keep( T1_after_3 T2_after_3 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean)) 
quietly sum p_ind_costumer  if T0 & period==0 & pilot==0
outreg2 [p_ind_costumer] using "behDDS3.xls", excel se append dec(3) keep( T1_after_3 T2_after_3 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))
quietly sum p_ind_total if T0 & period==0 & pilot==0
outreg2 [p_ind_total] using "behDDS3.xls", excel se append dec(3) keep( T1_after_3 T2_after_3 T1 T2) addtext(Controls, Yes) ctitle("`x'", "") addstat(Mean, r(mean))	




****************************************
***TABLE A.3: ACTUAL BEHAVIOR & NETWORK
****************************************

gen pair_1_T=.
gen pair_2_T=.

bys block: gen n = _n
sort n block

quietly{
forvalues i = 1/100 {
local a = treatment[`i']
local c = block[`i']
replace pair_1_T = `a' if pair_1==`c'
}
}

quietly{
forvalues i = 1/100 {
local a = treatment[`i']
local c = block[`i']
replace pair_2_T = `a' if pair_2==`c'
}
}

bys block: egen pair1_T = max(pair_1_T)
bys block: egen pair2_T = max(pair_2_T)

drop pair_1_T pair_2_T n

gen pair_1_T = pair1_T>0
gen pair_2_T = pair2_T>0
replace pair_1_T = . if pair1_T==.
replace pair_2_T = . if pair2_T==. 

gen neighbor_T = (pair_1_T==1|pair_2_T==1)

*This is a dummy for having at least one neighboring block be treated

gen TrXN = T*neighbor_T


********************************
***TABLE A.4: AWARENESS & NETWORK
********************************

foreach x in food_hygiene_any per_hygiene_any contamination_any utensils_any{
quietly{
reg `x' TrXN  T neighbor_T  $control if period==5, r cluster(block)
est store `x'
}
}

outreg2 [food_hygiene_any per_hygiene_any contamination_any utensils_any] using "Network_Aware.xls", excel append dec(3) keep( TrXN  T neighbor_T) addtext(Controls, Yes) ctitle("`x'")



********************************
***TABLE A.5: CLAIMED ACTIONS & NETWORK
********************************

foreach x in ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet{
quietly{
reg `x' TrXN  T neighbor_T  $control if period==5, r cluster(block)
est store `x'
}
}

outreg2 [ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet] using "Network_ClaimAct.xls", excel append dec(3) keep( TrXN  T neighbor_T) addtext(Controls, Yes) ctitle("`x'")



********************************
***TABLE A.6: TIME LAG
********************************

***Controlling for lag, to make sure that the T1-T2 difference is not being driven by the timing
***Running this without the control group 


gen lag_w1 = new_month- new_month_W1

***Unique treatment

foreach x in food_hygiene_any per_hygiene_any contamination_any utensils_any{
quietly{
reg `x' T1 T2 $control lag_w1 if period==5 & (T1==1|T2==1), r cluster(block)
est store `x'
}
}
outreg2 [food_hygiene_any per_hygiene_any contamination_any utensils_any] using "T1T2lag_aware.xls", excel append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'")


********************************
***TABLE A.7: T1 vs T2
********************************

foreach x in ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet{
quietly{
reg `x' T1 T2 $control lag_w1 if period==5 & (T1==1|T2==1), r cluster(block)
est store `x'
}
}

outreg2 [ad_discuss ad_info ad_improve ad_buy ad_disc_Act ad_info_Act ad_disc_union ad_meet] using "T1T2lag_claim.xls", excel append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'")


foreach x in p_ind_facilities p_ind_handling p_ind_costumer p_ind_total{
quietly{
areg `x' T1 T2 $control lag_w1 if (T1==1|T2==1), r absorb(period) cluster(block)
est store `x'
}
}

outreg2 [p_ind_facilities p_ind_handling p_ind_costumer p_ind_total] using "T1T2lag_beh.xls", excel append dec(3) keep( T1 T2) addtext(Controls, Yes) ctitle("`x'")




**********************************
***TABLE A.8: Business Variables 
**********************************

***Unique treatment


foreach x in revenue profits expenditure price_dish{
quietly{
areg `x' T_end T end $control if period==0|period==5, r absorb(period) cluster(block)
est store `x'
}
}

quietly sum revenue if T0 & period==0|period==5
outreg2 [revenue] using "bus1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum profits if T0 & period==0|period==5
outreg2 [profits] using "bus1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum expenditure if T0 & period==0|period==5
outreg2 [expenditure] using "bus1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum price_dish if T0 & period==0|period==5
outreg2 [price_dish] using "bus1.xls", excel se append dec(3) keep( T_end T) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))



***Separate Treatment

foreach x in revenue profits expenditure price_dish{
quietly{
areg `x' T1_end T2_end T1 T2 end $control, r absorb(period) cluster(block)
est store `x'
}
test T1_end=T2_end
}

quietly sum revenue if T0 & period==0|period==5
outreg2 [revenue] using "bus2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum profits if T0 & period==0|period==5
outreg2 [profits] using "bus2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum expenditure if T0 & period==0|period==5
outreg2 [expenditure] using "bus2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum price_dish if T0 & period==0|period==5
outreg2 [price_dish] using "bus2.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))

***Only for vendors who improved:

gen tot1 = p_ind_total if period==0
gen tot2 = p_ind_total if period==5
bys id: egen tot_old = max(tot1)
bys id: egen tot_new = max(tot2)
gen difftot = (tot_new>tot_old)
replace difftot = . if (tot_old==. | tot_new==.)

foreach x in revenue profits expenditure price_dish{
quietly{
areg `x' T1_end T2_end T1 T2 end $control if difftot==1, r absorb(period) cluster(block)
est store `x'
}
}

quietly sum revenue if T0 & difftot==1 
outreg2 [revenue] using "bus3.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum profits if T0 & difftot==1 
outreg2 [profits] using "bus3.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum expenditure if T0 & difftot==1 
outreg2 [expenditure] using "bus3.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))
quietly sum price_dish if T0 & difftot==1 
outreg2 [price_dish] using "bus3.xls", excel se append dec(3) keep( T1_end T2_end T1 T2) addtext(Controls, Yes) ctitle("`x'") addstat(Mean, r(mean))

